package com.ttg.web.dao.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ttg.common.utils.ListBeanUtil;
import com.ttg.model.pojo.QualityManageRuleList;
import com.ttg.model.mapper.QualityManageRuleListMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ttg.model.pojo.QualityManageTypeRule;
import com.ttg.model.vo.QualityManageRuleListVO;
import com.ttg.web.dao.QualityManageRuleListDao;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * (TblQualityManageTask) daoImpl
 *
 * @author chenyou
 * @datetime 2025-11-03 18:14:58
 */
@Service
public class QualityManageRuleListDaoImpl extends ServiceImpl<QualityManageRuleListMapper, QualityManageRuleList> implements QualityManageRuleListDao {

    @Override
    public List<QualityManageRuleListVO> getByDimType(Integer dimType) {
        LambdaQueryWrapper<QualityManageRuleList> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(QualityManageRuleList::getRuleDimType,dimType);
        List<QualityManageRuleList> list = list(wrapper);
        if(CollectionUtils.isEmpty(list)){
            return null;
        }
        return ListBeanUtil.copyListProperties(list,QualityManageRuleListVO::new);
    }

    @Override
    public QualityManageRuleList getParam(Integer dimType, Integer orderId) {
        LambdaQueryWrapper<QualityManageRuleList> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(QualityManageRuleList::getRuleDimType,dimType);
        wrapper.eq(QualityManageRuleList::getOrderId,orderId);
        return getOne(wrapper);
    }
}

